package com.cxx.aop;

import com.cxx.mapper.LogMapper;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class MyLog {
    @Autowired
    private LogMapper logMapper;
    @Pointcut("@annotation(com.cxx.log.Log)")
    public void pt(){
    }
    @Before("pt()")
    public void insertLog(JoinPoint joinPoint){
        String userName= joinPoint.getSignature().getName();
        String methodName=joinPoint.getTarget().toString();
        logMapper.insertLog(userName,methodName);
    }
}
